<template>
  <div class="eccount">
    <Title name="能源资源消费概况" :line="false">
      <stat-painting :data="stat" :decimals="true"></stat-painting
    ></Title>
  </div>
</template>

<script>
import Title from "@/components/Title";
import {} from "@/api/standingbook/month.js";
export default {
  name: "customer",
  components: {
    Title,
  },
  props: {
    tabData: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      stat: [],
    };
  },
  watch: {
    tabData: {
      handler(value) {
        if (value) {
          this.statSet(value);
        }
      },
    },
  },
  created() {
    this.statReset();
  },
  mounted() {},
  methods: {
    statReset() {
      this.stat = [
        {
          name: "单位面积能耗最高",
          num: 0,
          unit: "kwh/m²",
          img: require("@/assets/images/standingbook/standingbook-up.png"),
          bgImg: require("@/assets/images/index/Group-1.png"),
        },
        {
          name: "单位面积能耗最低",
          num: 0,
          unit: "kwh/m²",
          img: require("@/assets/images/standingbook/standingbook-down.png"),
          bgImg: require("@/assets/images/index/Group-2.png"),
        },
        {
          name: "人均能耗最高",
          num: 0,
          unit: "kwh/p",
          img: require("@/assets/images/standingbook/standingbook-height.png"),
          bgImg: require("@/assets/images/index/Group-3.png"),
        },
        {
          name: "人均能耗最低",
          num: 0,
          unit: "kwh/p",
          img: require("@/assets/images/standingbook/standingbook-low.png"),
          bgImg: require("@/assets/images/index/Group-4.png"),
        },
      ];
    },
    statSet(value) {
      if (value.perunitMax) {
        let num1 = (Number(value.perunitMax) / 100).toFixed(2);
        this.$set(this.stat[0], "num", num1);
        // console.log(num1);
      }
      if (value.perunitMin) {
        let num2 = (Number(value.perunitMin) / 100).toFixed(2);
        this.$set(this.stat[1], "num", num2);
        // console.log(num2);
      }
      if (value.percapitaMax) {
        let num3 = (Number(value.percapitaMax) / 100).toFixed(2);
        this.$set(this.stat[2], "num", num3);
        // console.log(num3);
      }
      if (value.percapitaMin) {
        let num4 = (Number(value.percapitaMin) / 100).toFixed(2);
        this.$set(this.stat[3], "num", num4);
        // console.log(num4);
      }
    },
  },
};
</script>

<style scoped lang="scss">
.eccount {
  .clearfix {
    // height: 22px;
    // width: 100%;
    margin-bottom: 20px;
    span {
      opacity: 0.8;
      &:nth-child(1) {
        text-align: left;
        font-size: 20px;
        font-weight: 600;
        color: #333333;
      }
    }
  }
}
</style>
